#ifndef _TIM_H
#define _TIM_H

/* FILE: TIM.h */
/****************************************************************************************/
/* MODULE NAME: MC9S12XS128 - TIM => TIMER                                              */
/*                                                                                      */
/* AUTHOR     : HUGUES ANGELIS                                                          */
/*                                                                                      */
/* EMAIL      : hugues.angelis@u-psud.fr                                                */
/*                                                                                      */
/* INSTITUTION: IUT de CACHAN - 9 av. de la div. Leclerc - 94230 CACHAN                 */
/*                                                                                      */
/* DATE       : 12/07/2012                                                              */
/* CPU        : FREESCALE MC9S12XS128MAA                                                */
/* BOARD      : CACHAN Xboard+MicroB12                                                  */
/* OS         : None                                                                    */
/*                                                                                      */
/* DESCRIPTION: Gestion des TIMERs                                                      */
/****************************************************************************************/

#include "ktypes.h"               

extern UINT8 TIM_is_running;
extern UINT8 PA_is_running;

typedef enum {
  kPRE1 = 1,
  kPRE2 = 2,
  kPRE4 = 4,
  kPRE8 = 8,
  kPRE16 = 16,
  kPRE32 = 32,
  kPRE64 = 64,
  kPRE128 = 128
} T_prescaler;

UINT32 TIM_init (UINT32 freq);

UINT32 TIM_generate_square (UINT8 channel, UINT32 freq);

UINT32 TIM_get_event_time (UINT8 channel);

UINT16 TIM_get_number_of_event (UINT16 periode);

#endif